define(function (require, exports, module) {
	var Grid = require("grid");
	var Dialog = require("dialog");
	var store =require("store");
	var activeUser = store.get("user");	
	var gridEvents = require("../handler/gridEvents");
	
    var instance = {
        initComponent: function (params, widget) {
            var grid = new Grid({
            	parentNode : ".J-grid",
            	url : "api/nonmemgroupreserve/query",
            	autoRender : false,
            	params : function(){
            		var subnav = widget.get("subnav");
            		var obj = {
            			"nonMemberGroup.status" : subnav.getValue("status"),
 //           			"nonMemberGroup.operator.pkUser":activeUser.pkUser,
            			"nonMemberGroup.operateDate" : subnav.getValue("operateDate").start,
            			"nonMemberGroup.operateDateEnd" : subnav.getValue("operateDate").end,
            			"nonMemberGroup.signUpType" : "Experience",
            			fetchProperties : "*,nonMemberGroup.*,nonMemberGroup.servicePoint.name," +
            					"nonMemberGroup.servicePoint.pkServicePoint," +
            					"nonMemberGroup.operator.pkUser," +
            					"nonMemberGroup.signUps.version," +
            					"nonMemberGroup.signUps.signUpRegister.exitGroup," +
            					"signUpRooms.roomType.*," +
            					"signUpRooms.count"
            		}
            		return obj;
            	},
            	model : {
            		columns:[{
            			name : "nonMemberGroup.contactName",
            			label : "联系人",
            		},{
            			name : "nonMemberGroup.contactPhone",
            			label : "联系方式",
            		},{
            			name : "nonMemberGroup.operateDate",
            			label : "登记日期",
            			format : "date"
            		},{
            			name : "nonMemberGroup.servicePoint.name",
            			label : "目的地"
            		},{
            			name : "roomType",
            			label : "房型",
            			format : function(value, row){
            				return row.signUpRooms[0].roomType.name;
            			}
            		},{
            			name : "signUpNumber",
            			label : "体验人数",
            			format : function(value, row){
            				return gridEvents.formatSignUpNumber(row.nonMemberGroup.signUps);
            			}
            		},{
            			name : "nonMemberGroup.deposit",
            			label : "订金金额",
            			format : function(value, row){
            				return value == null||value == "" ? "" : parseFloat(value).toFixed(2);
            			}
            		},{
            			name : "nonMemberGroup.status.value",
            			label : "体验状态",
            		},{
                        name : "show",
                        label : "操作",
    					format : "button",
						formatparams : [{
							id : "edit",
							text : "编辑",
							show:function(value,row){
								if(row.nonMemberGroup.status.key == "Initial"){
									return true;
								}else{
									return false
								}
							},
							handler : function(index,data,rowEle){
								gridEvents.editData(data, widget);
							}
						},{
							id : "delete",
							text : "删除",
							show:function(value,row){
								if(row.nonMemberGroup.status.key == "Initial"){
									return true;
								}else{
									return false
								}
							},
							handler : function(index,data,rowEle){
								gridEvents.deleteData(data, widget);
							}
						},{
							id : "check",
							text : "查看",
							show:function(value,row){
								if(row.nonMemberGroup.status.key == "Effective" || 
										row.nonMemberGroup.status.key == ""){
									return true;
								}else{
									return false
								}
							},
							handler : function(index,data,rowEle){
								gridEvents.checkData(data, widget);
							}
						}]
                    },]
        		}
            })
        	widget.set("grid", grid);
        }
    };
    module.exports = instance;
});
